<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title>layui</title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
		<link rel="stylesheet" href="__PUBLIC__/layui/css/layui.css" media="all">
		<link rel="stylesheet" href="__PUBLIC__/font-awesome/css/font-awesome.min.css" media="all" />
		<link rel="stylesheet" href="__CSS__/admin.css" media="all">
		<style type="text/css">
			/* tooltip */
		    #tooltip{
		      position:absolute;
		      border:1px solid #ccc;
		      background:#333;
		      padding:2px;
		      display:none;
		      color:#fff;
		    }
			
			.layui-btn-danger {
				background-color: #2BB6F6;
			} 
		</style>
	</head>

	<body style="padding:10px;">
		<div class="tplay-body-div">
			<div class="layui-tab">
				<ul class="layui-tab-title">
					<li class="layui-this"><a href="{:url('admin/special/spelist')}" class="a_menu">设备列表</a></li>
					<li><a href="{:url('admin/special/speadd')}" class="a_menu">新增设备</a></li>
				</ul>
			</div>
			<form class="layui-form serch" action="{:url('admin/special/spelist')}" method="post">
				<div class="layui-form-item" style="float: left;">
					<div class="layui-input-inline">
						<input type="text" name="machine_code" value="{$machine_code}" lay-verify="title" autocomplete="off" placeholder="前台打印机终端号" class="layui-input layui-btn-sm">
					</div> 
					<div class="layui-input-inline">
						<input type="text" name="machine_code1" value="{$machine_code1}" lay-verify="title" autocomplete="off" placeholder="传菜部打印机终端号" class="layui-input layui-btn-sm">
					</div>  
					<div class="layui-input-inline">
						<div class="layui-inline">
							<select name="store_id" lay-search="">
								<option value="">门店</option>
								{volist name="store" id="vo"}
								<option value="{$vo.id}" {if condition="$store_id eq $vo.id" }selected{/if}>{$vo.store_name}</option> 
								{/volist}
							</select>
						</div>
					</div> 
					<button class="layui-btn layui-btn-danger layui-btn-sm" lay-submit="" lay-filter="serch">查询</button>
				</div>
			</form>
			<table class="layui-table" lay-size="sm">
				<colgroup>
					<col width="100">
					<col width="100">
					<col width="100">
					<col width="100">
					<col width="100">
					<col width="100">
					<col width="100">
					<col width="100">
					<col width="100">
				</colgroup>
				<thead>
					<tr>
						<th>门店名称</th>
						<th>会员姓名</th> 
						<th>前台打印机终端号</th>
						<th>前台打印机密钥</th>
						<th>传菜部打印机终端号</th>
						<th>传菜部打印机密钥</th> 
						<th>前台打印机开关</th>
						<th>传菜部打印机开关</th> 
						<th>操作</th> 
					</tr>
				</thead>
				<tbody>
					{volist name="list" id="vo"}
					<tr>
						<td>{$vo.store_name}</td>
						<td>{$vo.user_name}</td>
						<td>{$vo.machine_code}</td>
						<td>{$vo.msign}</td>
						<td>{$vo.machine_code1}</td>
						<td>{$vo.msign1}</td>
						<td>
							<form class="layui-form" action="" lay-filter="example">  
							    <input type="checkbox" {if $vo.paid==0 }checked{/if} data-id="{$vo.id}" lay-skin="switch" lay-filter="status" lay-text="开|关">
							</form>
						</td>
						<td>
							<form class="layui-form" action="" lay-filter="example">  
							    <input type="checkbox" {if $vo.store_switch==0 }checked{/if} data-id="{$vo.id}" lay-skin="switch" lay-filter="status1" lay-text="开|关">
							</form>
						</td>
						<td>
							<a href="{:url('admin/special/speedit',['id'=>$vo.id])}" style="font-size:12px;color: #2BB6F6;">设置</a> 
						</td>
					</tr>
					{/volist}
				</tbody>
			</table>
			<div style="padding:0 20px;">{$list->render()}</div>

			{include file="public/foot"}
			<script>
            	layui.use(['form', 'layedit', 'laydate'], function() {
					var form = layui.form;
			        var jquery = layui.jquery;
			        var layer = layui.layer;
			        
			        //前台打印机开关
					form.on('switch(status)', function(data) {
						var checked = this.checked;
						var flag = 0; //0开启  1关闭
						var id = $(this).attr('data-id'); //id
						var msg = "确定要开启吗";
						if(checked == false) {
							flag = 1;
							msg = "确定要关闭吗";
						} 
						
						layer.confirm(msg, {
							btn: ['确定', '取消'] //按钮
						}, function() {
							prt_status(flag,id);
						});
					});
					
					//传菜部打印机开关
					form.on('switch(status1)', function(data) { 
						var checked = this.checked;
						var flag = 0; //0开启  1关闭
						var id = $(this).attr('data-id'); //id
						var msg = "确定要开启吗";
						if(checked == false) {
							flag = 1;
							msg = "确定要关闭吗";
						} 
						
						layer.confirm(msg, {
							btn: ['确定', '取消'] //按钮
						}, function() {
							store_switch(flag,id);
						});
					});
            	})
            	
            	function prt_status(is_status,id){   
    		    	$.ajax({
						type: 'post',
						url: "{:url('special/prt_status')}",
						dataType: 'json',
						data: {
							id: id,
							paid: is_status
						},
						success: function(data) { 
							layer.msg(data.msg, {
								icon: 1,
								time: 1000
							}); 
						}
					});
            	}
            	
            	function store_switch(is_status,id){   
    		    	$.ajax({
						type: 'post',
						url: "{:url('special/store_switch')}",
						dataType: 'json',
						data: {
							id: id,
							store_switch: is_status
						},
						success: function(data) { 
							layer.msg(data.msg, {
								icon: 1,
								time: 1000
							}); 
						}
					});
            	}
            </script>
		</div>
	</body>

</html>